package org.funtester.performance.books.chapter07.section3;

import com.alibaba.fastjson.JSON;

/**
 * 用户个人信息类
 */
public class User {

    /**
     * 用户ID
     */
    public int id;

    /**
     * 用户名
     */
    public String name;

    /**
     * 用户年龄
     */
    public int age;

    /**
     * 用户地址
     */
    public String address;

    public User(int id, String name, int age, String address) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.address = address;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

    /**
     * 从字符串中初始化对象
     * @param string
     * @return
     */
    public static User init(String string) {
        return JSON.parseObject(string, User.class);
    }

}
